import { h } from 'vue';
import { NTag } from 'naive-ui';
export const columns: any[] = [
	{
		title: '组织名称',
		key: 'deptName',
		// sorter: true,
	},
	{
		title: '状态',
		key: 'status',
		render: (record) => {
			const status = record.status;
			const enable = ~~status === 0;
			const type = enable ? 'success' : 'error';
			const text = enable ? '启用' : '停用';
			return h(NTag, { type: type }, () => text);
		},
	},
	{
		title: '创建时间',
		key: 'createTime',
	},
	{
		title: '备注',
		key: 'remark',
	},
];

export const searchFormSchema: any[] = [
	{
		field: 'deptName',
		label: '组织名称',
		component: 'NInput',
		colProps: { span: 8 },
		componentProps: {
			placeholder: '请输入组织名称',
			onInput: (e: any) => {
				console.log(e);
			},
		},
	},
	{
		field: 'status',
		label: '状态',
		component: 'NSelect',
		componentProps: {
			options: [
				{ label: '启用', value: '0' },
				{ label: '停用', value: '1' },
			],
		},
		colProps: { span: 8 },
	},
];

export const formSchema: any[] = [
	{
		field: 'deptName',
		label: '组织名称',
		component: 'Input',
		required: true,
	},
	{
		field: 'parentDept',
		label: '上级组织',
		component: 'TreeSelect',
		componentProps: {
			replaceFields: {
				title: 'deptName',
				key: 'id',
				value: 'id',
			},
			getPopupContainer: () => document.body,
		},
		required: true,
	},
	{
		field: 'orderNo',
		label: '排序',
		component: 'InputNumber',
		required: true,
	},
	{
		field: 'status',
		label: '状态',
		component: 'RadioButtonGroup',
		defaultValue: '0',
		componentProps: {
			options: [
				{ label: '启用', value: '0' },
				{ label: '停用', value: '1' },
			],
		},
		required: true,
	},
	{
		label: '备注',
		field: 'remark',
		component: 'InputTextArea',
	},
];
